/*
* Copyright (c) 2025 Huawei Device Co., Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including but not limited to the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to provide persons with access to the Software
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGE OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

<template>
  <MultiDiversionVue :direction='multiDiversionDirection'>
    <DiversionItemVue name='firstPart' :diversionCols='contentCols'>
      <div class='recommended-product-view' :style='gapStyle'>
        <img
          class='recommended-product-view-main'
          src='../../assets/recommended_product_1.png'
        />
        <img
          class='recommended-product-view-overlay'
          src='../../assets/icon_video.png'
        />
      </div>
    </DiversionItemVue>
    <DiversionItemVue name='secondPart' :diversionCols='contentCols'>
      <div class='second-view'>
        <div class='welfare-view'>
          <div class="welfare-view-area">
            <div class='welfare-view-title'>
              <span class='welfare-view-title1'>福利专区</span>
              <span class='welfare-view-title2'>立即领券</span>
            </div>
            <div class='welfare-view-context'>
              <div class='welfare-view-context-child'>
                <img
                  class='welfare-view-context-child1'
                  src='../../assets/welfare_product_1.png'
                />
                <span class='welfare-view-context-child2'>用券价</span>
                <span class='welfare-view-context-child3'>￥1299起</span>
              </div>
              <div class='welfare-view-context-child'>
                <img
                  class='welfare-view-context-child1'
                  src='../../assets/categories_9.png'
                />
                <span class='welfare-view-context-child2'>用券价</span>
                <span class='welfare-view-context-child3'>￥899起</span>
              </div>
              <div class='welfare-view-context-child'>
                <img
                  class='welfare-view-context-child1'
                  src='../../assets/welfare_product_5.png'
                />
                <span class='welfare-view-context-child2'>用券价</span>
                <span class='welfare-view-context-child3'>￥599起</span>
              </div>
            </div>
          </div>
        </div>
        <div class='selection'>
          <div class="selection-area">
            <div class='selection-title'>
              <h3>甄选推荐</h3>
              <div>更多<img src='../../assets/ic_arrow_right_grey.png' /></div>
            </div>
            <div class='selection-context'>
              <div class='selection-context-child'>
                <img
                  class='selection-context-child1'
                  src='../../assets/section_product_1.png'
                />
                <span class='selection-context-child2'>MateBook X Pro 12代</span>
                <div class='selection-context-child3'></div>
                <span class='selection-context-child4'>V1-V5优惠400元</span>
                <span class='selection-context-child5'>￥10999</span>
                <span class='selection-context-child6'>2571人评论 95%好评</span>
              </div>
              <div class='selection-context-child'>
                <img
                  class='selection-context-child1'
                  src='../../assets/section_product_2.png'
                />
                <span class='selection-context-child2'>HUAWEI Mate50</span>
                <span class='selection-context-child3'>北斗卫星消息</span>
                <span class='selection-context-child4'>新一代直屏旗舰机</span>
                <span class='selection-context-child5'>￥10999</span>
                <span class='selection-context-child6'>2571人评论 95%好评</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </DiversionItemVue>
  </MultiDiversionVue>
</template>

<script>
import { breakpointManager } from '../../utils/breakpointInit';
import {
  MultiDiversionVue,
  DiversionItemVue,
} from 'web-multidevice-advanced-vue2/src';

export default {
  name: 'RecommendedArea',
  components: {
    MultiDiversionVue,
    DiversionItemVue,
  },
  data() {
    return {
      multiDiversionDirection: 'vertical',
      contentCols: 6,
      gapStyle: 'margin-bottom: 15px;',
    };
  },
  mounted() {
    this.unsubscribe = breakpointManager.subscribeToBreakpoint(() => {
      this.multiDiversionDirection = breakpointManager.useBreakpointValue({
        xs: 'vertical',
        sm: 'vertical',
        md: 'horizontal',
        lg: 'horizontal',
        xl: 'horizontal',
      });

      this.contentCols = breakpointManager.useBreakpointValue({
        xs: 12,
        sm: 12,
        md: 6,
        lg: 6,
        xl: 6,
      });

      this.gapStyle = breakpointManager.useBreakpointValue({
        xs: 'margin-bottom: 15px;',
        sm: 'margin-bottom: 15px;',
        md: 'margin-right: 25px;',
        lg: 'margin-right: 25px;',
        xl: 'margin-right: 25px;',
      });
    });
  },
  beforeDestroy() {
    if (this.unsubscribe) {
      this.unsubscribe();
    }
  },
};
</script>

<style lang='less' scoped>
@import './index.less';
</style>